package com.itheima.utils;

public class IndexUtils {
    public static int start(int currentPage, int pageSize, int totalPage) {
        int startIndex = 1;
        startIndex = currentPage - 5;
        if (startIndex > totalPage - 9) {
            startIndex = totalPage - 9;
        }
        if (startIndex <= 0) {
            startIndex = 1;
        }
        return startIndex;
    }

    public static int end(int currentPage, int startIndex, int totalPage) {
        int endIndex = totalPage;
        if (endIndex > startIndex + 9) {
            endIndex = startIndex + 9;
        }
        if (endIndex > totalPage) {
            endIndex = totalPage;
        }
        return endIndex;
    }
}
